<template>
  <div class="crumb">
    <el-breadcrumb separator="/">
      <template v-for="item in breadCrumb" :key="item.name">
        <!-- 这里的 to 要整一个路由重定向，定向到每个当前的第一个子菜单 -->
        <el-breadcrumb-item :to="item.path">{{ item.name }}</el-breadcrumb-item>
      </template>
    </el-breadcrumb>
  </div>
</template>

<script setup lang="ts">
import { computed, watch, reactive } from 'vue'
import { useRoute } from 'vue-router'
import { mapPathToBreadcrumbs } from '@/utils/map-menus'
import useLoginAccountStore from '@/store/login/login'

const route = useRoute()
const loginStore = useLoginAccountStore()
const userMenus = loginStore?.userMenus

let breadCrumb = computed(() => {
  return mapPathToBreadcrumbs(route.path, userMenus)
})
</script>

<style lang="less" scoped>
.crumb {
  margin-left: 5px;
}
</style>
